# 生成图形验证码
from captcha.image import ImageCaptcha
import random
import string
from PIL import Image


def createImageCode():
    characters = string.digits + string.ascii_uppercase
    width, height, n_len, n_class = 170, 80, 4, len(characters)
    generator = ImageCaptcha(width=width, height=height)
    random_str = ''.join([random.choice(characters) for j in range(4)])
    img = generator.generate_image(random_str)
    img.save(r'D:\project\mido-mall\meiduo_mall\meiduo_mall\static\images\veri_code.jpg')
    return random_str, img
